﻿using Ejemplo_vacio_sin_uso.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Ejemplo_vacio_sin_uso.Controllers
{
     [AllowAnonymous] 


    public class HomeController : Controller
    {

         private UrnaVirtualContext db = new UrnaVirtualContext();

        
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

       
        //Validacion del dni

         public ActionResult IngresoDni(long dni_num)
        {

            if (dni_num == 0)
            {
                var resultado = db.Personas;
                return View("Error");
            }
            else
            {
                Persona resultado = (from dt in db.Personas
                                where dt.DNI == dni_num
                                select dt).FirstOrDefault();

                if (resultado != null)
                {
                    return RedirectToAction("Index", "Votar", new { DNI = resultado.DNI });
                    //Ir al index para votar
                }
                else 
                {
                    return View("Error");
                    //mostrar error
                }
            }


         }
    }
}
